# Makefile
CXX      = g++
CC       = gcc
CXXFLAGS = -I. -I  $(HPCKIT_PATH)/latest/hmpi/gcc/release/hmpi/include -L$(HPCKIT_PATH)/latest/hmpi/gcc/release/hmpi/lib/
CFLAGS   = -I. -I  $(HPCKIT_PATH)/latest/hmpi/gcc/release/hmpi/include -L$(HPCKIT_PATH)/latest/hmpi/gcc/release/hmpi/lib/
LDFLAGS  = -lgtest -lgtest_main -lpthread -L. -lkfft -lkfftf -lkffth -lkblas -lklapack_full -lm -lksolver -lmpi -lkscalapack_full -lkipl -lkconv -lkm -lkvml -lkvsl -lksvml -lkspblas

TARGET   = test_kml
SOURCES_C = kml_fft_test.c kml_blas_test.c kml_lapack_test.c kml_solver_test.c kml_scalapack_test.c kml_ipl_test.c kml_conv_test.c kml_vml_test.c kml_vsl_test.c kml_svml_test.c kml_math_test.c kml_spblas_test.c
SOURCES_CPP = kml_test_main.cpp
OBJECTS_C = $(SOURCES_C:.c=.o)
OBJECTS_CPP = $(SOURCES_CPP:.cpp=.o)
OBJECTS = $(OBJECTS_C) $(OBJECTS_CPP)

# 默认目标
all: $(TARGET)

# 构建可执行文件
$(TARGET): $(OBJECTS)
	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS) $(CXXFLAGS)

# 编译 C 文件
%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

# 编译 C++ 文件
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# 清理
clean:
	rm -f *.o $(TARGET)

rebuild: clean all

.PHONY: all clean rebuild